<template>
  <div id="shopclassifylist"> 

          <el-table :data="datalist" style="width: 100%" :height="dtheight" :header-cell-style="{background:'#4F81BC',color:'white'}"
           :row-class-name="tableRowClassName"  :border="true">
                
                <el-table-column label="排序"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.rank }}</span>
                    </template>
                </el-table-column>

                <el-table-column label="轮播名称"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.title }}</span>
                    </template>
                </el-table-column>  
                <el-table-column label="产品名称"  align='center' >                   
                    <template slot-scope="scope">                   
                        <span >{{ scope.row.pname }}</span>
                    </template>
                </el-table-column> 

                <el-table-column label="图片"  align='center' >                   
                    <template slot-scope="scope">                   
                         <img  style="width: 30px; height: 30px" :src="urlimg + scope.row.picture" /> 
                    </template>
                </el-table-column> 
  
               
                 <el-table-column label="操作" align='center' width="300px">
                    <template slot-scope="scope"> 
                        <el-button size="mini"  type="primary" class="button_class2"  plain @click="delect_but(scope.row)">删除</el-button>
                        <el-button size="mini"  type="primary" class="button_class1"  plain @click="mtk1_but(scope.row)">排序</el-button>
                    </template>
                </el-table-column>        

  
            </el-table>  


    
               <!-- 修改排序 -->
    <el-dialog title="修改排序" :visible.sync="mtk1"  width="400px" :close-on-click-modal="false">
        <div style="width:100%;"> 


        <el-form ref="form"   label-width="70px" style="width:100%;">
    
             <el-form-item label="排序">
                    <el-input    v-model="mtk1_form.num" placeholder="排序"></el-input>
              </el-form-item> 
 
                                     
            </el-form>

            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;"  @click="mtk1_but_qr">确认</el-button>
                
            </div>

        </div> 
    </el-dialog>

   </div>
</template>

<script>

export default {
   name: 'shopclassifylist',
   props:{
      datalist:{  
        //type:Array,
       default:()=>[]
     },
  },
  data () {
    return {
        dtheight:'500',  //窗口高度 
        my_id:'',
        mtk1:false,
        mtk1_form:{
            num:''
        }
    }
  },
   components:{

  },
  created(){
     this.dtheight = window.innerHeight - 293
      
  },
  mounted (){
    
    
  },
  methods: {
    delect_but(row){
        this.my_id = row.id
        this.$confirm('是否删除, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
         }).then(() => {
                this.post("/product_lunbo/delete", {
                    id:row.id,
                }).then(res => {

                    if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.$emit('up_list_fun')
                    }else {
                    this.open1(res.message,'warning')
                }

             })
        }).catch(() => {
                  this.$emit('up_list_fun') 
        });
     },
     mtk1_but(row){
         this.my_id = row.id
         this.mtk1_form.num = row.rank
         this.mtk1 = true
     },
     mtk1_but_qr(){
        this.post("/product_lunbo/sort", {
                    id:this.my_id,
                    num:this.mtk1_form.num
                }).then(res => {

                    if(res.error_code == 0){
                    this.open1(res.result,'success')  //提示框
                    this.$emit('up_list_fun')
                    this.mtk1 = false
                    }else {
                    this.open1(res.message,'warning')
                }

             })
     },

  }
}
</script>


<style scoped>
.avatar-uploader  {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 150px;
    height: 150px;
    line-height: 150px;
    text-align: center;
  }
  .avatar {
    width: 150px;
    height: 150px;
    display: block;
  }
</style>